#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"

int main(void) {
	
	SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); //// System clock

    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); //// ENable uart
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); ///// ENable gpio

    GPIOPinConfigure(GPIO_PA0_U0RX); ///// Set PA0 to recieve
    GPIOPinConfigure(GPIO_PA1_U0TX); ///// Set PA1 to transmit
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); ///// Set the pin to UART

    UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
        (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); ///// Inititalizes the communication protocol. 115200 baud, 8 length, stop 1, no parity check


	/////// Characters to send
    UARTCharPut(UART0_BASE, 'E');
    UARTCharPut(UART0_BASE, 'n');
    UARTCharPut(UART0_BASE, 't');
    UARTCharPut(UART0_BASE, 'e');
    UARTCharPut(UART0_BASE, 'r');
    UARTCharPut(UART0_BASE, ' ');
    UARTCharPut(UART0_BASE, 'T');
    UARTCharPut(UART0_BASE, 'e');
    UARTCharPut(UART0_BASE, 'x');
    UARTCharPut(UART0_BASE, 't');
    UARTCharPut(UART0_BASE, ':');
    UARTCharPut(UART0_BASE, ' ');

    while (1)
    {


    	if (UARTCharsAvail(UART0_BASE)){ ///// Checks for avaliable data
    		char testSend = UARTCharGet(UART0_BASE); //// Get the uart character
    		if(testSend>=65&&testSend<=90) testSend+=32; /// Makes capital to lower
    		else if(testSend>=97&&testSend<=122) testSend-=32; ////// Makes lower to capital
    		UARTCharPut(UART0_BASE, testSend); ///////// Output through the UART

    	}
    }

}
